/*
   BroserRouter  |  HashRouter 
*/
import { BrowserRouter as Router, Route, Switch } from "react-router-dom"
import App from "../App"
import Home from "../pages/Home"
import Fast from "../pages/Fast"
import User from "../pages/User"
import Error from "../pages/Error"
import Login from "../pages/Login"
import Register from "../pages/Register"
import Practice from "../pages/Practice"
import Exam from "../pages/Exam"
import Toggle from "../pages/Toggle"

// 创建路由组件
const router = () => (
  <Router>
    <Switch>
      <Route path="/" component={() => (
        <App>
          <Switch>
            <Route exact path="/home" component={Home}></Route>
            <Route exact path="/fast" component={Fast}></Route>
            <Route exact path="/user" component={User}></Route>
            <Route exact path="/login" component={Login}></Route>
            <Route exact path="/register" component={Register}></Route>
            <Route exact path="/practice/:actionCode" component={Practice}></Route>
            <Route exact path="/exam" component={Exam}></Route>
            <Route exact path="/toggle" component={Toggle}></Route>
            <Route exact path="*" component={Error}></Route>
          </Switch>
        </App>
      )}>
      </Route>
    </Switch>
  </Router>
)

export default router;